define(function(require, exports, module) {

	var $ = require('jquery');
	var List = require('../util/list');
	require('artTemplate/artTemplate/2.0.1/template.js');
	require('seajs/seajs/2.1.1/sea.js');
	var id =g_user.id;
	exports.showFinanceList = function showDepositList() {
		var depositList = new List();
		depositList.options.template = "financeList-template";
		depositList.options.container = "#financeList";
		depositList.options.links = { "list" : $CONFIG.base_url + "/api/fund_detail/list" };
		depositList.options.params = {"action_type":"5","s":"10","p":"1"};
		depositList.load();
	};	
	exports.showFinanceList();
	$("#financeList").on("click",".accept-btn",function(){
		var data=$.parseJSON($(this).attr("data"));
		fundNo=data.no;
		var uid=data.id;
		var fund=data.amount;
		var postting=$.post($CONFIG.base_url + "/api/admin/confirmCash",{Fund_no:fundNo});
		postting.done(function(){
			var msg="您申请提现"+fund+"元的交易已经成功，请注意查收！";
            var postData={"messageTo":{"id":uid},"messageFrom":{"id":id},"content":msg};
			postData=$.toJSON(postData);
			$.ajax({
				url : $CONFIG.base_url+ "/api/message/add",
				type : "POST",
				data : postData,
				contentType : "application/json",
				success : function(data) {
					$.jBox.tip("提现成功！并成功发送站内信");
					exports.showFinanceList();
				},
				error : function() {
				}
			});
		});
	});
	$("#financeList").on("click",".regist-btn",function(){
		var data=$.parseJSON($(this).attr("data"));
		fundNo=data.no;
		var uid=data.id;
		var fund=data.amount;
		var postting=$.post($CONFIG.base_url + "/api/admin/refuseCash",{Fund_no:fundNo});
		postting.done(function(){
			var msg="您申请提现"+fund+"元的交易已经失败，请重试！";
            var postData={"messageTo":{"id":uid},"messageFrom":{"id":id},"content":msg};
			postData=$.toJSON(postData);
			$.ajax({
				url : $CONFIG.base_url+ "/api/message/add",
				type : "POST",
				data : postData,
				contentType : "application/json",
				success : function(data) {
					$.jBox.tip("拒绝成功！并成功发送站内信");
					exports.showFinanceList();
				},
				error : function() {
				}
			});
		});
	});
		
});